<?php

namespace app\web\controller;

use think\App;
use think\Controller;
use think\Request;
use app\web\services\IndexService;

class Index extends Controller
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->IndexService = new IndexService();
    }

    /**
     * 导航栏处理
     */
    public function getNavMsg()
    {
        $res = $this->IndexService->getNavMsg();
        if ($res['status'] != 0) {
            $this->error('执行错误');
        }
        $res = $res['data'];
        foreach ($res as $k => $v) {
            if ($v['states'] == 1) {
                $this->assign("title", $v['title']);
            }
        }
        $this->assign("navdata", $res);
    }

    /**
     * 网站首页
     */
    public function index()
    {
        $this->getNavMsg();
        $data = $this->IndexService->lotterytype();
        $nicto = $this->IndexService->Nicton();
        $webdata = $this->IndexService->weblist();
        $agentlist = $this->IndexService->agent();
        $this->assign('agentlist',$agentlist);
        $this->assign('page',$agentlist['page']);
        $this->assign('webdata',$webdata);
        $this->assign('nicto',$nicto);
        $this->assign('lettr',$data);
        return $this->fetch();
    }

    /**
     * 实例页面
     */
    public function example()
    {
        $this->getNavMsg();
        $newdata = $this->IndexService->Newtitle(); //获取案例头条
        $beslist = $this->IndexService->beslist(); //获取案例列表
        $brof = $this->IndexService->brolist();//获取简介列表
        $money = $this->IndexService->listmoney(); //获取收费列表
        $this->assign('money',$money);
        $this->assign('brof',$brof);
        $this->assign('beslist',$beslist);
        $this->assign('page',$beslist['page']);
        $this->assign('newdata',$newdata);
        return $this->fetch();
    }

    /**
     * 实例详情页面
     */
    public function example_detail()
    {
        $this->assign("title", "实例详情");
        return $this->fetch();
    }

    /**
     * 手册页面
     */
    public function manual()
    {
        $id = input('get.id');
        $this->getNavMsg();
        $this->assign("title", "手册");
        $grs = new \app\web\services\ManualGroupService();
        $pdata = $grs->getParentList();
        $seletedId=0;
        if(!empty($pdata) && empty($id)){
            $data = $grs->getDataList($pdata[0]['id']);
            $seletedId = $pdata[0]['id'];
        }else{
            $data = $grs->getDataList($id);
            $seletedId = $id;
        }
        $this->assign('id',$seletedId);
        $this->assign('pdata',$pdata);
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 问题页面
     */
    public function problem()
    {
        $this->getNavMsg();
        return $this->fetch();
    }

    /**
     * 充值页面
     */
    public function recharge()
    {
        $this->assign("title", "充值");
        return $this->fetch();
    }

    /**
     * 银行选择
     */
    public function bank()
    {
        $this->getNavMsg();
        return $this->fetch();
    }

    /**
     * 手册页面
     */
    public function right()
    {
        $this->assign("title", "手册页面");
        $grs = new \app\web\services\ManualService();
        $data = $grs->getDataById();
        $this->assign('data',$data);
        return $this->fetch();
    }
    
    /**
     * @搜索手册
     */
    public function searchManual(){
        $grs = new \app\web\services\ManualService();
        $data = $grs->getList();
        return json($data);
    }

    /**
     * @param 获取代理信息内容
     */
    public function sectrt(){
        $data = $this->IndexService->sectrt();
        return json($data);
    }


    /**
     * @param 获取当前案例信息
     */
    public function movert(){
        $data = $this->IndexService->movert();
        return json($data);
    }
}